package com.yhq.spring.order.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author hqyin
 * @date 2023/4/18 5:12 下午
 */
@Component
@Slf4j
public class InterceptorOrdered3 implements HandlerInterceptor, Ordered {
    public InterceptorOrdered3() {
        log.info("========>Ordered3初始化");
    }

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.info("============>Ordered3 preHandle");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        log.info("============>Ordered3 postHandle");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.info("============>Ordered3 afterCompletion");
    }

    @Override
    public int getOrder() {
        return 4;
    }
}
